import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ul'
if (process.env.NODE_ENV === 'development') {
  // import 'element-ui/lib/theme-chalk/index.css'
  require('element-ui/lib/theme-chalk/index.css')
}
// eslint-disable-next-line no-unused-vars
import locale from 'element-ui/lib/locale/lang/en' // lang i18n

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control
import '@/directives/index' // 引入自定义图片加载失败指令
import '@/filters'

// 引入全局组件
// import '@/components'
// 高级写法
import Ui from '@/components'
Vue.use(Ui)
// 批量注册过滤器
import * as filters from '@/filters/index'
// 1. 循环对象方式 for in
for (var k in filters) {
  Vue.filter(k, filters[k])
}
/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */
// if (process.env.NODE_ENV === 'production') {
//   const { mockXHR } = require('../mock')
//   mockXHR()
// }

// set ElementUI lang to EN
// Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
Vue.use(ElementUI, {
  i18n: (key, value) => i18n.t(key, value)
})

// 在vue全局放方法-方式1-原型链
// Vue.prototype.hasPerm = function(key) {
//   return this.$store.getters.points.includes(key)
// }
// 在vue全局放方法-方式2-混入
import '@/mixins'
import '@/utils/mock'

Vue.config.productionTip = false
import i18n from '@/lang/index.js'

new Vue({
  el: '#app',
  router,
  store,
  i18n, // 挂载,给所有组件, 添加this.$xxx.
  render: h => h(App)
})
// 默认情况下,import/require都回去node_modules去找
// import moment from 'moment'
const moment = window.moment
console.log(moment().format('YYYY'))
